import 'package:bxultimate/data/request/shop_request.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

import 'state.dart';

class MerchantEnterAnnexController extends GetxController {
  final MerchantEnterAnnexState state = MerchantEnterAnnexState();

  var text = '';

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();

    getData();
  }

  void getData() async {
    state.shop = await ShopRequest.getShopDetail(Get.arguments['id']);
    if (state.shop.shopDetails != null) {
      text = state.shop.shopDetails!;
    }
  }

  void save() async {
    await ShopRequest.updateShop(
        {"id": Get.arguments['id'], "shopDetails": text});

    SmartDialog.showNotify(msg: '提交成功', notifyType: NotifyType.success);
    Get.back();
  }

  onTextChanged(String p1) {
    text = p1;
  }
}
